<template>

	<view>
		<uni-nav-bar right-text="新增" title="仪表列表" fixed="true" statusBar="true"  @clickLeft="leftAction" left-text="使用情况"
			@clickRight="rightAction"></uni-nav-bar>

		<uni-list>
			<template v-for="(item,index) in listData">
				<uni-list-item :title="item.name" :note="item.address" clickable link rightText="查看"
					@click="onClickItem(index)" />
					
			</template>
			<uni-load-more :status="status" @clickLoadMore="clickLoadMore" :content-text="contentText"></uni-load-more>
			
		</uni-list>
	</view>
</template>

<script>
	import uniNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
	import uLoadMore from '@/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue'
	
	export default {
		data() {
			return {
				listData: [],
				page: 1,
				status: 'more',
				contentText: {
					contentdown: '查看更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				}
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.page = 1;
			this.status = "more";
			this.getList()
		},
		components: {
			uniNavBar
		},
		onPullDownRefresh() {
			this.page = 1;
			this.status = "more";
			this.getList();
		},
		
		methods: {
			getList() {
				console.log("开始获取数据 page :" + this.page);
				if (this.page == 1) {
					this.listData = []
				}else{
					
				}
				this.$http.get('/netty/station/list',{params: {'pageNum': this.page, 'pageSize': 10}}).then(res => {
					console.log(res.data);
					const list = res.data.rows;
					this.listData = this.reload ? result.list : this.listData.concat(list);
					uni.stopPullDownRefresh();
					if (this.listData.length == res.data.total){
						this.status = "noMore"
					}
				}).catch(err => {
					console.log("出错了 err:" + err);
				});
			},
			leftAction() {
				uni.navigateTo({
					url:"../useList/useList"
				})
			},
			rightAction() {
				
				try {
				    // uni.setStorageSync('isEdit', false);
					uni.navigateTo({
						url: "../editBasestation/editBasestation?isEdit=0",
					})
				} catch (e) {
				    
				}
			},
			onClickItem(index) {
				const item = this.listData[index];
				console.log(item.id);
				uni.navigateTo({
					url: "../basestationInfo/basestationInfo?id=" + item.id +"&title="+item.name
				})
			},
			clickLoadMore(e) {
				if(this.status == "noMore"){
					return;
				}
				this.page++;
				this.getList();
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/common/uni-nvue.scss';
</style>
